import React from "react";
import './index.css'
class HeaderTodo extends React.Component{
 
   handleKeyUp=(e)=>{
      const{value}=e.target;
    if(e.keyCode!==13){
      return

    }
    else if(value===''){
    alert('输入内容不能为空')
    }
    else{
   const newTodos={
     id:Math.random(),
     name:value,
     done:true,
   }
   this.props.addTodo(newTodos)
    }     
   }

   render(){
  return(
   <div className="todo-header">
   <input type='text' placeholder="请输入内容后按回车键添加信息" onKeyUp={this.handleKeyUp}/>
   <button>点击搜索</button>
   {/* <input
    type='text'
    placeholder="请输入内容"
    onChange={this.handeleChange}
    // value={this.states.name}
    /> */}
   </div>
  )
   }
}


export default HeaderTodo;